//注册
var btn = document.getElementById("btn");
var username = document.getElementById("username");
var password = document.getElementById("password");
var rpassword = document.getElementById("rpassword");
var nickname = document.getElementById("nickname");


btn.onclick = async function () {
      let url = "http://127.0.0.1:8888/users/register"
      let foo = {
            method: "POST",
            headers: { "Content-Type": "application/x-www-form-urlencoded" },
            body: `username=${username.value}&password=${password.value}&rpassword=${rpassword.value}&nickname=${nickname.value}`

      }
      let a = await fetch(url, foo);
      let data = await a.json();
      if(data.code === 1){
            alert("注册成功正在跳转页面")

      setInterval(function(){
                  location.href="register.html"
            },2000)
      }else{
            alert(data.message)
      }
}
